//
//  MainViewController.m
//  tangshantongjiAPP
//
//  Created by yuntai on 2018/4/3.
//  Copyright © 2018年 yuntai. All rights reserved.
//

#import "MainViewController.h"
#import "UIButton+TextImage.h"
#import "MineViewController.h"
#import "NSString+Time.h"
#import "PPIVideoViewController.h"
#import "PriceListViewController.h"

@interface MainViewController ()
@property (strong, nonatomic) IBOutletCollection(UIButton) NSArray *btnArrays;
@property (weak, nonatomic) IBOutlet UILabel *titleLabel;
@property (weak, nonatomic) IBOutlet UIButton *backBtn;

@end

@implementation MainViewController
- (IBAction)backAction:(UIButton *)sender {
    [self.navigationController popViewControllerAnimated:YES];
}

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    if(TangShanTongJiAPPFull){
        self.backBtn.hidden = NO;
    }else{
        self.backBtn.hidden = YES;
    }
    [self initUI];
    self.titleLabel.text = [NSString getNowTime];

}
-(void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
//    self.navigationController.navigationBar.hidden = YES;
    [self.navigationController setNavigationBarHidden:YES animated:YES];

}
-(void)viewWillDisappear:(BOOL)animated{
    [super viewWillDisappear:animated];
    [self.navigationController setNavigationBarHidden:NO animated:YES];
}
/**个人中心*/
- (IBAction)rightBtnAction:(UIButton *)sender {
    
//     MineViewController *vc =  [[UIStoryboard storyboardWithName:@"Main" bundle:[NSBundle mainBundle] ] instantiateViewControllerWithIdentifier:@"MineVC"];
    MineViewController *vc =  [[MineViewController alloc]init];
    [self.navigationController pushViewController:vc animated:YES];
    
}
- (IBAction)btnsAction:(UIButton *)sender {
    
    switch (sender.tag) {
        case 0:
        {
            PriceListViewController *vc =  [[UIStoryboard storyboardWithName:@"Main" bundle:[NSBundle mainBundle] ] instantiateViewControllerWithIdentifier:@"PriceListvc"];
            vc.type = PriceProduceUpLoad;
            [self.navigationController pushViewController:vc animated:YES];
        }
            break;
            
        case 1:
        {
            PriceListViewController *vc =  [[UIStoryboard storyboardWithName:@"Main" bundle:[NSBundle mainBundle] ] instantiateViewControllerWithIdentifier:@"PriceListvc"];
            vc.type = PriceProduceFix;
            [self.navigationController pushViewController:vc animated:YES];
        }
            break;
            
            
        case 2:
        {
            PriceListViewController *vc =  [[UIStoryboard storyboardWithName:@"Main" bundle:[NSBundle mainBundle] ] instantiateViewControllerWithIdentifier:@"PriceListvc"];
            vc.type = PriceBuyUpLoad;
            [self.navigationController pushViewController:vc animated:YES];
        }
            break;
            
            
        case 3:
        {
            PriceListViewController *vc =  [[UIStoryboard storyboardWithName:@"Main" bundle:[NSBundle mainBundle] ] instantiateViewControllerWithIdentifier:@"PriceListvc"];
            vc.type = PriceBuyFix;
            [self.navigationController pushViewController:vc animated:YES];
        }
            break;
            
            
        case 4:
        {
            PPIVideoViewController *vc = [[PPIVideoViewController alloc]init];
            [self.navigationController pushViewController:vc animated:YES];
        }
            break;
            
    }
}

- (void)initUI{
    UIView *topView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, kScreenBoundWidth,   kNavigationHeight-44)];
    topView.backgroundColor = kNavigationColor;
    [self.view addSubview:topView];
    
    NSArray *nameArray = [NSArray arrayWithObjects:@"出厂价格资料上传",@"出厂价格资料修改",@"购进价格资料上传",@"购进价格资料修改",@"PPI专业培训视频",@"", nil];
    NSArray *iamgeNameArray = [NSArray arrayWithObjects:@"ic_ppi",@"ic_data_up",@"ic_buy_up",@"ic_buy_change",@"ic_video_look",@"", nil];
    
    [self.btnArrays enumerateObjectsUsingBlock:^(UIButton *  _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
        
        if (idx == 5) {
            obj.hidden = YES;
            
        }
        if (IS_IPHONE5) {
            obj.titleLabel.font = [UIFont systemFontOfSize:14];
        }
        obj.layer.cornerRadius = 2.2f;
        obj.layer.masksToBounds = YES;
        [obj setImage:[UIImage imageNamed:iamgeNameArray[idx]] forState:UIControlStateNormal];
        [obj setTitle:nameArray[idx] forState:UIControlStateNormal];
        [obj verticalImageAndTitle:5.f];
    }];
    
}

@end
